class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2021-12-04",
      revision: "34c9d56d78fe575bd409ab4b959b55a1ba0837f1"
  version "2021-12-04"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git", branch: "master"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_monterey: "ca81e2b5596e14fef39a72de37238aa0eb3265644597419c20d308e56389b78d"
    sha256 cellar: :any_skip_relocation, arm64_big_sur:  "6c27825b8cc870b25ed8fcfff77c521f85f6ba184f46f01b1c8864a6017a7c1a"
    sha256 cellar: :any_skip_relocation, monterey:       "d11311311158a60f4798ae415312d0069b6a3fc2a37c239ac1da6a87413b5871"
    sha256 cellar: :any_skip_relocation, big_sur:        "27fd435e848baaead841c30e0e2527d5270c94b0460332520da9ce43dd006d36"
    sha256 cellar: :any_skip_relocation, catalina:       "3b8482f04676f51ccba2c7a2c74206252bb0b323f86a3d96744b9b3bc6e7a37a"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "8c172e4456544e0c081489a2224b8fa14899e938fd025fb43dbfdeb95a40b4dc"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
